<%@page import="study.itwill.team5.admin.AdminItem"%>
<%@page import="study.itwill.jsp.WebHandler"%>
<%@page import="study.itwill.team5.member.Member"%>
<%@page import="study.itwill.common.PatternChecker"%>
<%@page import="study.itwill.common.DBHandler"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true"%>
<%@ include file="../session.jsp"%>
<%@ include file="../dbcon.jsp"%>
<%
	PatternChecker checker = PatternChecker.getInstance();

	// 모든 파라미터 받기
	int seq = web.getInt("seq");
	String email1 = web.getValue("email1");
	String email2 = web.getValue("email2");
	String nickname = web.getValue("nickname");
	String user_pw = web.getValue("user_pw");
	String user_name = web.getValue("user_name");
	String gender = web.getValue("gender");
	String birthday = web.getValue("birthday");
	String hp1 = web.getValue("hp1");
	String hp2 = web.getValue("hp2");
	String hp3 = web.getValue("hp3");
	
	if (seq == -1) {
		db.disconnect();
		web.goPage(null, "파라미터가 잘못되었습니다.");
		return;
	}
	
	if (!checker.isValue(email1) || !checker.isValue(email2)) {
		db.disconnect();
		web.goPage(null, "파라미터가 잘못되었습니다.");
		return;
	}
	
	if (!checker.isValue(nickname)) {
		db.disconnect();
		web.goPage(null, "파라미터가 잘못되었습니다.");
		return;
	}
	
	if (!checker.isValue(user_pw)) {
		db.disconnect();
		web.goPage(null, "파라미터가 잘못되었습니다.");
		return;
	}
	
	if (!checker.isValue(user_name)) {
		db.disconnect();
		web.goPage(null, "파라미터가 잘못되었습니다.");
		return;
	}
	
	if (!checker.isValue(gender) || !checker.isEng(gender)) {
		db.disconnect();
		web.goPage(null, "파라미터가 잘못되었습니다.");
		return;
	}
	
	if (!checker.isValue(birthday)) {
		db.disconnect();
		web.goPage(null, "파라미터가 잘못되었습니다.");
		return;
	}
	
	if (!checker.isValue(hp1) || !checker.isValue(hp2) || !checker.isValue(hp3)) {
		db.disconnect();
		web.goPage(null, "파라미터가 잘못되었습니다.");
		return;
	}
%>
<%
	/** 데이터 저장 */
	Member member = new Member();
	boolean result = member.editMember(seq, email1, email2, nickname, user_pw, user_name, gender, birthday, hp1, hp2, hp3);
	
	/** 접속 해제 */
	db.disconnect();
	
	// 페이지 강제 이동 (JSP)
	web.goPage("viewMember.jsp?seq=" + seq, null);
%>